package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;

import com.ruoyi.system.domain.AProcessLog;
import com.ruoyi.system.service.IAProcessLogService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 业务流程日志Controller
 * 
 * @author ruoyi
 * @date 2025-04-02
 */
@RestController
@RequestMapping("/log")
public class AProcessLogController extends BaseController
{
    @Autowired
    private IAProcessLogService aProcessLogService;

    /**
     * 查询业务流程日志列表
     */
    @RequiresPermissions("logs:log:list")
    @GetMapping("/list")
    public TableDataInfo list(AProcessLog aProcessLog)
    {
        startPage();
        List<AProcessLog> list = aProcessLogService.selectAProcessLogList(aProcessLog);
        return getDataTable(list);
    }

    /**
     * 导出业务流程日志列表
     */
    @RequiresPermissions("logs:log:export")
    @Log(title = "业务流程日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AProcessLog aProcessLog)
    {
        List<AProcessLog> list = aProcessLogService.selectAProcessLogList(aProcessLog);
        ExcelUtil<AProcessLog> util = new ExcelUtil<AProcessLog>(AProcessLog.class);
        util.exportExcel(response, list, "业务流程日志数据");
    }

    /**
     * 获取业务流程日志详细信息
     */
    @RequiresPermissions("logs:log:query")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return success(aProcessLogService.selectAProcessLogByLogId(logId));
    }

    /**
     * 新增业务流程日志
     */
    @RequiresPermissions("logs:log:add")
    @Log(title = "业务流程日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AProcessLog aProcessLog)
    {
        return toAjax(aProcessLogService.insertAProcessLog(aProcessLog));
    }

    /**
     * 修改业务流程日志
     */
    @RequiresPermissions("logs:log:edit")
    @Log(title = "业务流程日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AProcessLog aProcessLog)
    {
        return toAjax(aProcessLogService.updateAProcessLog(aProcessLog));
    }

    /**
     * 删除业务流程日志
     */
    @RequiresPermissions("logs:log:remove")
    @Log(title = "业务流程日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(aProcessLogService.deleteAProcessLogByLogIds(logIds));
    }
}
